package com.ziyun.erp.web.modules.configPointSku.controller;

import java.util.Arrays;
import java.util.Map;

import com.baomidou.mybatisplus.plugins.Page;
import com.ziyun.erp.modules.goods.entity.GoodsAttributeEntity;
import io.renren.common.validator.ValidatorUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.ziyun.erp.modules.configPointSku.entity.ConfigPointSkuEntity;
import com.ziyun.erp.modules.configPointSku.service.ConfigPointSkuService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 积分商品表
 *
 * @author xueqz
 * @email 
 * @date 2018-09-17 11:27:00
 */
@RestController
@RequestMapping("configPointSku/configpointsku")
public class ConfigPointSkuController {
    @Autowired
    private ConfigPointSkuService configPointSkuService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("configPointSku:configpointsku:list")
    public R list(Page<ConfigPointSkuEntity> page,@RequestParam Map<String, Object> params){
        page.setSize(Integer.parseInt((String) params.get("limit")));
        page.setCurrent(Integer.parseInt((String) params.get("page")));
        Page<ConfigPointSkuEntity> resultPage = configPointSkuService.queryPageNew(page, params);
//        PageUtils pageUtils = configPointSkuService.queryPage(params);
        return R.ok().put("page", resultPage);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("configPointSku:configpointsku:info")
    public R info(@PathVariable("id") Integer id){
        ConfigPointSkuEntity configPointSku = configPointSkuService.selectById(id);

        return R.ok().put("configPointSku", configPointSku);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("configPointSku:configpointsku:save")
    public R save(@RequestBody ConfigPointSkuEntity configPointSku){
        configPointSkuService.insert(configPointSku);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("configPointSku:configpointsku:update")
    public R update(@RequestBody ConfigPointSkuEntity configPointSku){
        ValidatorUtils.validateEntity(configPointSku);
        configPointSkuService.updateAllColumnById(configPointSku);//全部更新
        
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("configPointSku:configpointsku:delete")
    public R delete(@RequestBody Integer[] ids){
        configPointSkuService.deleteBatchIds(Arrays.asList(ids));

        return R.ok();
    }

}
